package com.dkm.ec.sale.persistence.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.dkm.base.api.model.Page;
import com.dkm.base.db.mybatis.dao.MyBatisQueryDaoImpl;
import com.dkm.ec.sale.persistence.dao.SaleEntityQueryDao;
import com.dkm.ec.sale.persistence.entity.SaleEntityPo;

/**
 * 对象功能:销售产品实体 QueryDao接口的实现 开发公司:SKG.COM 开发人员:Yuki 创建时间:2015-01-16 15:23:27
 */
@Repository
public class SaleEntityQueryDaoImpl extends MyBatisQueryDaoImpl<String, SaleEntityPo> implements SaleEntityQueryDao {

	@Override
	public String getNamespace() {
		return SaleEntityPo.class.getName();
	}

	@Override
	public SaleEntityPo getSaleEntityPoByKey(String key) {
		return getByKey("", b().a("key", key).p());
	}

	@Override
	public List<SaleEntityPo> findProdRec(String userId, String productId, Integer count) {
		// TODO Auto-generated method stub
		return (List<SaleEntityPo>) getByKey("findRecEntity", b().a("userId", userId).a("productId", productId).a("rowsCount", count).p());
	}
	
	@Override
	public List<SaleEntityPo> find2(Map<String,Object> paraMap) {
		return findByKey("find2",paraMap);
	}	

	@Override
	public List findProdByUpdateTime(String startTime, String endTime,Page pager) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("startTime", startTime);
		params.put("endTime", endTime);
		return findByKey("findProdByUpdateTime", params,pager);
	}

	@Override
	public String findAttrIdByEavSetKey(String eavSetKey) {
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("eavSetKey", eavSetKey);
		return sqlSessionTemplate.selectOne(getNamespace()+ ".findAttrIdByEavSetKey", params);
	}

	@Override
	public int findProdByUpdateTimeCount(String startTime, String endTime) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("startTime", startTime);
		params.put("endTime", endTime);
		return sqlSessionTemplate.selectOne(getNamespace()+ ".findProdByUpdateTimeCount", params);
	}
}
